//
//  MyPrescriptionOrderModel.swift
//  EyeVisionForPatients
//
//  Created by PMC on 2021/8/9.
//  Copyright © 2021 QDSG. All rights reserved.
//

import HandyJSON

/// 处方订单状态
/// 0未审核 1待支付 2驳回 3待发货 4已发货 5已完成 6待取药 7已取消 8申请退药 9待寄出 10药品寄回中 11已退药 12-取消退药或拒绝
/// 103申请退药-待发货 104申请退药-已发货 105申请退药-已完成 106申请退药-待取药
/// 204取消退药-未收货 205申请退药-已收货
enum PrescriptionOrderStatus: Int, HandyJSONEnum {
    case unreview, waitPay, reject, waitShip, shipped, completed, waitTake, canceled, applyRefund, waitSendOut, sendingBack, refunded, cancelRefund, waitShipApplyRefund = 103, shippedApplyRefund = 104, completeApplyRefund = 105, waitTakeApplyRefund = 106, waitSendOutUnreceived = 204, waitSendOutReceived = 205
    
    var statusTextColor: UIColor {
        switch self {
        case .waitPay,
             .reject,
             .waitShip,
             .shipped,
             .waitTake,
             .applyRefund,
             .waitSendOut,
             .sendingBack,
             .waitShipApplyRefund,
             .shippedApplyRefund,
             .completeApplyRefund,
             .waitTakeApplyRefund,
             .waitSendOutUnreceived,
             .waitSendOutReceived:  return .warning
        case .completed,
             .canceled,
             .refunded:     return .textLight
        default:            return .clear
        }
    }
    
    var rightTitle: String? {
        switch self {
        case .waitPay:      return "立即支付"
        case .shipped:      return "确认收货"
        case .applyRefund,
             .waitShipApplyRefund,
             .shippedApplyRefund,
             .completeApplyRefund,
             .waitTakeApplyRefund:  return "取消退药"
        case .waitSendOut,
             .waitSendOutUnreceived,
             .waitSendOutReceived:  return "录入快递单"
        case .sendingBack:  return "等待医院确认后自动退款"
        case .refunded:     return "药品费用在24小时内原路退回"
        default:            return nil
        }
    }
    
    var centerTitle: String? {
        switch self {
        case .shipped:  return "查看物流"
        default:        return nil
        }
    }
    
    var leftTitle: String? {
        switch self {
        case .waitPay:      return "取消订单"
        case .waitShip,
             .shipped,
             .waitTake,
             .completed:    return "申请退药"
        case .waitSendOut,
             .waitSendOutUnreceived,
             .waitSendOutReceived:  return "取消退药"
        default:            return nil
        }
    }
    
    var bottomLabelText: String? {
        switch self {
        case .sendingBack: return "等待医院确认后自动退款"
        default:           return nil
        }
    }
    
    var centerIsHidden: Bool {
        switch self {
        case .shipped:  return false
        default:        return true
        }
    }
    
    var rightIsHidden: Bool {
        switch self {
        case .waitPay,
             .shipped,
             .waitSendOut,
             .applyRefund,
             .waitShipApplyRefund,
             .shippedApplyRefund,
             .completeApplyRefund,
             .waitTakeApplyRefund,
             .waitSendOutUnreceived,
             .waitSendOutReceived:  return false
        default:            return true
        }
    }
    
    var bottomLabelHidden: Bool {
        switch self {
        case .sendingBack: return false
        default:           return true
        }
    }
    
    var styleLabelHidden: Bool {
        switch self {
        case .reject: return true
        default:      return false
        }
    }
}

struct PrescriptionOrderList: HandyJSON {
    var records: [PrescriptionOrder]?
    var pages: Int = 0
    var total: Int = 0
    var size: Int = 0
    var current: Int = 0
}

/**
 {
   "expressNum" : "",
   "prescriptionId" : "1247804580620877826",
   "remainPayTime" : "0",
   "orderStatus" : "407",
   "prescriptionList" : "庆大霉素针、",
   "status" : 1,
   "docId" : "1158208471743139841",
   "deptName" : "儿童眼底病专科",
   "canCancel" : false,
   "prescriptionAmount" : "0.00",
   "url" : "https:\/\/ylttest.qdsgvision.com:10214\/medicalPic\/head\/20201013-30\/6eaaf9ff-4e93-4bf0-8adc-336f32694b4d",
   "canDelete" : false,
   "orderId" : "1247804581845614594",
   "express" : "",
   "doctorName" : "陈峰",
   "statusName" : "待支付"
 }
 */
struct PrescriptionOrder: HandyJSON {
    var url: String?
    var doctorName: String?
    var deptName: String?
    var status: PrescriptionOrderStatus?
    var statusName: String?
    var express: String?
    var expressNum: String?
    var canCancel: Bool = false
    var canDelete: Bool = false
    var remainPayTime: String?
    var orderId: String?
    var prescriptionId: String?
    var prescriptionList: String?
    var prescriptionAmount: String?
    var receiveType: PrescriptionOrderReceiveType?
}


